import * as actionTypes from '../constants/member';

const initialState = {
  isLogin: false,
  userInfo: {},
  loginButtonDisabled: true,
  forgetButtonDisabled: true,
  registerButtonDisabled: true
};

export default (state = initialState, action ) => {

  switch (action.type) {
    case actionTypes.MEMBER_LOGIN_STATE:
      return {...state, isLogin: true, userInfo: action.data};

    case actionTypes.LOGIN_BUTTON_STATE:
      return {...state, loginButtonDisabled: action.isDisabled};

    case actionTypes.FORGET_BUTTON_STATE:
      return {...state, forgetButtonDisabled: action.isDisabled};

    case actionTypes.REGISTER_BUTTON_STATE:
      return {...state, registerButtonDisabled: action.isDisabled};

    default:
      return state;
  }

}